<?
// Database Connection
$dbname = 'tcntrans_main';
$dbhost = 'localhost';
$dbuser = 'tcntrans';
$dbpass = 'hJV65VUX';
$db = mysql_connect($dbhost,$dbuser,$dbpass);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
	<title>New document</title>
<meta name="generator" content="TSW WebCoder">
</head>

<body>
<h1>Updating Orphaned Records</h1>
<?
$row = 1;
$handle = fopen("orphans.csv", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
    $num = count($data);
    echo "<p> $num fields in line $row: <br /></p>\n";
    $row++;
    
    $linkID  = $data[0];
    $pathOld = $data[1];
    $pathNew = $data[2];
    $title   = $data[3];
    $link    = $data[4];
    $output  = 'LinkID: '.$linkID.'<br>';
    $output .= 'Path Old: '.$pathOld.'<br>';
    $output .= 'Path New: '.$pathNew.'<br>';
    $output .= 'Title: '.$title.'<br>';
    $output .= 'Link: '.$link.'<hr>';
    //echo $output;
    
    // Update database
    $sql = "UPDATE transLinks SET
    			Path  = '$pathNew',
    			Title = '$title',
    			Link  = '$link'
    		WHERE
    			LinkID = $linkID";
    $result = mysql_db_query($dbname,$sql);
    echo $sql.'<hr>';
    			
    
}
fclose($handle);
?>


</body>
</html>